/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.EmbeddedId;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author Elias Mendoza
 */
@Entity
@Table(name="sensor_registro_sustrato",uniqueConstraints={@UniqueConstraint(columnNames={"id_sensor_reg","id_sustrato"})})
public class SensorRegistroSustrato implements Serializable{
  @Id
  private int id;
  @Column(name="estado_valvula",nullable=false)
  private String estadoValvula;
  @JoinColumn(name="id_sensor_reg", referencedColumnName="id",nullable=false)
  @ManyToOne()
  private SensorRegistro sensorRegistroFK;
  @JoinColumn(name="id_sustrato", referencedColumnName="id",nullable=false)
  @ManyToOne()
  private Sustrato sustratoFK;
  

  public SensorRegistroSustrato() {
  }

  public String getEstadoValvula() {
    return estadoValvula;
  }

  public void setEstadoValvula(String estadoValvula) {
    this.estadoValvula = estadoValvula;
  }
  public void addEstado(String e){
    estadoValvula+=e;
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public SensorRegistro getSensorRegistroFK() {
    return sensorRegistroFK;
  }

  public void setSensorRegistroFK(SensorRegistro sensorRegistroFK) {
    this.sensorRegistroFK = sensorRegistroFK;
  }

  public Sustrato getSustratoFK() {
    return sustratoFK;
  }

  public void setSustratoFK(Sustrato sustratoFK) {
    this.sustratoFK = sustratoFK;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    final SensorRegistroSustrato other = (SensorRegistroSustrato) obj;
    if (this.id != other.id) {
      return false;
    }
    if (this.sensorRegistroFK != other.sensorRegistroFK && (this.sensorRegistroFK == null || !this.sensorRegistroFK.equals(other.sensorRegistroFK))) {
      return false;
    }
    if (this.sustratoFK != other.sustratoFK && (this.sustratoFK == null || !this.sustratoFK.equals(other.sustratoFK))) {
      return false;
    }
    return true;
  }

  @Override
  public int hashCode() {
    int hash = 3;
    hash = 97 * hash + this.id;
    hash = 97 * hash + (this.sensorRegistroFK != null ? this.sensorRegistroFK.hashCode() : 0);
    hash = 97 * hash + (this.sustratoFK != null ? this.sustratoFK.hashCode() : 0);
    return hash;
  }
  
  
}
